package ru.ssau.university.web.beans;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

import ru.ssau.university.web.util.WebUtil;

@ManagedBean(name = "enterBean")
@RequestScoped
public class EnterBean {

	private String password;
	private String userName;
	
	public EnterBean() {

	}
	
	public String doLogin() {
		boolean loggedInOK = WebUtil.getAuthBean().loginAsAdmin(userName, password);
		if (loggedInOK) {
			return "pretty:welcome";
		} else {
		 	WebUtil.putError("User or password is incorrect");
			return null;
		}
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}
	
}
